#ifndef _IMAGE_H_
#define _IMAGE_H_

#include <string>
#include <SDL/SDL_opengl.h>
#include "Vector.h"
#include "Rect.h"
namespace fe
{
    class Window;
    class Image
    {
    public:
        Image();
        Image(const std::string& name);

        ~Image();

        void load(const std::string &file);

        void render(Window& window);
        //void renderRaw(Window& w, int x, int y, int clipx, int clipy, int clipw, int cliph);
        //void renderRaw(Window& w, int x, int y);

        void rotate(float x, float y);

        void setPosition(float x, float y);
        void move(float offx, float offy);
        void setAlpha(float alpha);
        void setClip(float x, float y, float w, float h);

        inline float getX() { return m_location.x; }
        inline float getY() { return m_location.y; }

        inline VectorF getPosition() const { return m_location; }

        inline float getWidth() const { return m_width; }
        inline float getHeight() const{ return m_height; }
        inline float getAlpha() const { return m_alpha; }

        inline RectF getRect() const  {
            return RectF(m_location.x, m_location.y,
                         m_width, m_height );
        }

        inline RectF getClip() const {
            return RectF(m_clip[0].x, m_clip[0].y,
                         m_width, m_height);
        }

    private:
        void update();

        GLuint m_texture;

        float m_alpha, m_imageWidth, m_imageHeight;

        VectorF m_position[4];

        std::string m_filename;

        VectorF m_clip[4];

        VectorF m_location;

        float m_width, m_height;

        float m_rotX, m_rotY;

    };
}

#endif
